package cn.com.scitc.soft2101.servlet.paid;

import cn.com.scitc.soft2101.dao.PaidDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

// 动作：删除
@WebServlet(urlPatterns = "/paid/delete")
public class PaidDeleteServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        try {
            Integer id = Integer.parseInt(req.getParameter("id"));
            PaidDao paidDao = new PaidDao();
            paidDao.delete(id);

            req.getSession().setAttribute("msg", "删除成功");
        }
        catch (NumberFormatException er) {
            req.getSession().setAttribute("msg", "删除失败");
            er.printStackTrace();
        }
        resp.sendRedirect("list");
    }
}
